﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace Project
{
    public partial class updateProject : Form
    {
        public updateProject()
        {
            InitializeComponent();
        }

        private void updateProject_Load(object sender, EventArgs e)
        {

        }

        private void btn_back_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void btn_update_Click(object sender, EventArgs e)
        {
            string start = "UPDATE tbl_Projects SET";
            StringBuilder query = new StringBuilder();
            query.Append(start);
            if (chck_name.Checked)
                query.Append(" ,fld_projectName='" + txt_name.Text + "'");
            if (chck_cid.Checked)
                query.Append(" ,fld_clientID='" + txt_cid.Text + "'");
            if (chck_sid.Checked)
                query.Append(" ,fld_supervisorID='" + txt_sid.Text + "'");
            if (chck_description.Checked)
                query.Append(" ,fld_description='" + txt_description.Text + "'");
            try
            {
                query.Remove(start.Length + 1, 1);
            }
            catch
            {
                MessageBox.Show("Please choose at least one field", "Error");
            }
            query.Append(" WHERE fld_projectID LIKE '" + txt_id.Text + "'");
            Projects.updateProject(query.ToString());
        }
    }
}
